#include <iostream>
#include <vector>

using namespace std;

class Step
{
public:
    int steps[7]; // 一周的步数
    int maxStep, minStep, averStep;

    Step(int mon, int tus, int wed, int thu, int fri, int sat, int sun)
    {
        steps[0] = mon;
        steps[1] = tus;
        steps[2] = wed;
        steps[3] = thu;
        steps[4] = fri;
        steps[5] = sat;
        steps[6] = sun;

        maxStep = 0;
        minStep = 0;
        averStep = 0;
    }

    void getMax()
    {
        maxStep = steps[0];
        for (int i = 0; i < 7; i++)
        {
            if (steps[i] > maxStep)
                maxStep = steps[i];
        }
    }

    void getMin()
    {
        minStep = steps[0];
        for (int i = 0; i < 7; i++)
        {
            if (steps[i] < minStep)
                minStep = steps[i];
        }
    }

    void getAverage()
    {
        int sum = 0;
        for (int i = 0; i < 7; i++)
            sum += steps[i];
        averStep = sum / 7;
    }

    void showAnswer()
    {
        cout << maxStep << endl
             << minStep << endl
             << averStep << endl;
    }
};

int main(int argc, char const *argv[])
{
    vector<Step> vec;
    vector<Step>::iterator iter;
    int mon, tus, wed, thu, fri, sat, sun;

    int count;
    cin >> count;

    for (int i = 0; i < count; i++)
    {
        cin >> mon >> tus >> wed >> thu >> fri >> sat >> sun;
        vec.emplace_back(mon, tus, wed, thu, fri, sat, sun);
    }

    for (iter = vec.begin(); iter != vec.end(); ++iter)
    {
        iter->getMax();
        iter->getMin();
        iter->getAverage();
        iter->showAnswer();
    }

    return 0;
}
